/* 动画和过渡效果 */

/* 基础动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-2px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(2px);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* 聊天特定动画 */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes messageHighlight {
  0% {
    background-color: transparent;
  }
  50% {
    background-color: var(--color-primary-alpha);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes statusBlink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0.3;
  }
}

@keyframes notificationSlide {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 动画类 */
.animate-fade-in {
  animation: fadeIn var(--duration-300) ease-out;
}

.animate-fade-out {
  animation: fadeOut var(--duration-300) ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft var(--duration-300) ease-out;
}

.animate-slide-in-right {
  animation: slideInRight var(--duration-300) ease-out;
}

.animate-slide-in-up {
  animation: slideInUp var(--duration-300) ease-out;
}

.animate-slide-in-down {
  animation: slideInDown var(--duration-300) ease-out;
}

.animate-scale-in {
  animation: scaleIn var(--duration-200) ease-out;
}

.animate-bounce {
  animation: bounce var(--duration-1000) ease-out;
}

.animate-pulse {
  animation: pulse var(--duration-1000) ease-in-out infinite;
}

.animate-shake {
  animation: shake var(--duration-500) ease-in-out;
}

.animate-spin {
  animation: spin var(--duration-1000) linear infinite;
}

.animate-typing {
  animation: typing 1.4s infinite ease-in-out;
}

.animate-shimmer {
  animation: shimmer 1.5s infinite;
}

/* 聊天动画类 */
.animate-message-in {
  animation: messageSlideIn var(--duration-300) ease-out;
}

.animate-message-highlight {
  animation: messageHighlight var(--duration-1000) ease-out;
}

.animate-status-blink {
  animation: statusBlink var(--duration-1000) infinite;
}

.animate-notification-slide {
  animation: notificationSlide var(--duration-300) ease-out;
}

/* 延迟动画 */
.animate-delay-75 {
  animation-delay: var(--duration-75);
}

.animate-delay-100 {
  animation-delay: var(--duration-100);
}

.animate-delay-150 {
  animation-delay: var(--duration-150);
}

.animate-delay-200 {
  animation-delay: var(--duration-200);
}

.animate-delay-300 {
  animation-delay: var(--duration-300);
}

.animate-delay-500 {
  animation-delay: var(--duration-500);
}

/* 过渡效果类 */
.transition-all {
  transition: all var(--transition-base);
}

.transition-colors {
  transition: color var(--transition-base), background-color var(--transition-base), border-color var(--transition-base);
}

.transition-opacity {
  transition: opacity var(--transition-base);
}

.transition-transform {
  transition: transform var(--transition-base);
}

.transition-shadow {
  transition: box-shadow var(--transition-base);
}

.transition-fast {
  transition-duration: var(--transition-fast);
}

.transition-slow {
  transition-duration: var(--transition-slow);
}

.transition-slower {
  transition-duration: var(--transition-slower);
}

/* 悬停效果 */
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

.hover-brightness:hover {
  filter: brightness(1.1);
}

/* 焦点效果 */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-alpha);
}

.focus-ring-error:focus {
  box-shadow: 0 0 0 3px rgba(var(--color-error-rgb), 0.2);
}

/* 加载状态 */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--color-border);
  border-top: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: spin var(--duration-1000) linear infinite;
}

/* 禁用状态 */
.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* 视差效果 */
.parallax {
  transform: translateZ(0);
  will-change: transform;
}

/* 3D 效果 */
.transform-3d {
  transform-style: preserve-3d;
}

/* GPU 加速 */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* 响应式动画控制 */
@media (prefers-reduced-motion: reduce) {
  .respect-motion-preference,
  .respect-motion-preference * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .animate-pulse {
    animation: none;
  }
  
  .animate-spin {
    animation: none;
  }
  
  .animate-bounce {
    animation: none;
  }
}

/* 高性能动画 */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

.will-change-scroll {
  will-change: scroll-position;
}

/* 动画组合 */
.animate-fade-slide-up {
  animation: fadeIn var(--duration-300) ease-out, slideInUp var(--duration-300) ease-out;
}

.animate-scale-fade {
  animation: scaleIn var(--duration-200) ease-out, fadeIn var(--duration-200) ease-out;
}

/* 交互反馈动画 */
.click-feedback:active {
  transform: scale(0.98);
  transition: transform var(--duration-75);
}

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width var(--duration-300), height var(--duration-300);
}

.ripple:active::before {
  width: 300px;
  height: 300px;
}